package com.appoint.buss.service.impl;

import com.appoint.buss.domain.EpiparaAtacSeq;
import com.appoint.buss.domain.req.EpiparaAtacSeqReqVO;
import com.appoint.buss.domain.vo.EpiparaAtacSeqRespVO;
import com.appoint.buss.mapper.EpiparaAtacSeqMapper;
import com.appoint.buss.service.AsyncAtacSeqService;
import com.appoint.buss.service.IEpiparaAtacSeqService;
import com.appoint.common.exception.ServiceException;
import com.appoint.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * epipara_atac_seqService业务层处理
 *
 * @author appoint
 * @date 2023-01-15
 */
@Service
public class EpiparaAtacSeqServiceImpl extends ServiceImpl<EpiparaAtacSeqMapper, EpiparaAtacSeq> implements IEpiparaAtacSeqService
{
    @Resource
    private EpiparaAtacSeqMapper epiparaAtacSeqMapper;

    @Autowired
    private AsyncAtacSeqService asyncAtacSeqService;

    /**
     * 查询epipara_atac_seq
     *
     * @param id epipara_atac_seq主键
     * @return epipara_atac_seq
     */
    @Override
    public EpiparaAtacSeq selectEpiparaAtacSeqById(String id)
    {
        return epiparaAtacSeqMapper.selectById(id);
    }

    /**
     * 查询epipara_atac_seq列表
     *
     * @param epiparaAtacSeq epipara_atac_seq
     * @return epipara_atac_seq
     */
    @Override
    public List<EpiparaAtacSeq> selectEpiparaAtacSeqList(EpiparaAtacSeq epiparaAtacSeq)
    {
        return epiparaAtacSeqMapper.selectEpiparaAtacSeqList(epiparaAtacSeq);
    }

    /**
     * 新增epipara_atac_seq
     *
     * @param epiparaAtacSeq epipara_atac_seq
     * @return 结果
     */
    @Override
    public int insertEpiparaAtacSeq(EpiparaAtacSeq epiparaAtacSeq)
    {
        epiparaAtacSeq.setId(IdWorker.getIdStr());
        return epiparaAtacSeqMapper.insertEpiparaAtacSeq(epiparaAtacSeq);
    }

    /**
     * 修改epipara_atac_seq
     *
     * @param epiparaAtacSeq epipara_atac_seq
     * @return 结果
     */
    @Override
    public int updateEpiparaAtacSeq(EpiparaAtacSeq epiparaAtacSeq)
    {
        return epiparaAtacSeqMapper.updateEpiparaAtacSeq(epiparaAtacSeq);
    }

    /**
     * 批量删除epipara_atac_seq
     *
     * @param ids 需要删除的epipara_atac_seq主键
     * @return 结果
     */
    @Override
    public int deleteEpiparaAtacSeqByIds(Long[] ids)
    {
        return epiparaAtacSeqMapper.deleteEpiparaAtacSeqByIds(ids);
    }

    /**
     * 删除epipara_atac_seq信息
     *
     * @param id epipara_atac_seq主键
     * @return 结果
     */
    @Override
    public int deleteEpiparaAtacSeqById(Long id)
    {
        return epiparaAtacSeqMapper.deleteEpiparaAtacSeqById(id);
    }

    @Override
    public String importUser(List<EpiparaAtacSeq> list, Boolean isUpdateSupport, String operName) {
        if (StringUtils.isNull(list) || list.size() == 0) {
            throw new ServiceException("导入数据不能为空！");
        }
        String resultMsg = "恭喜您，数据已全部导入成功！共 " + list.size() + " 条";
        try {
            asyncAtacSeqService.saveAtacSeq(list);
        } catch (Exception e) {
            resultMsg  = "很抱歉，导入失败！";
            log.error(resultMsg, e);
        }
        return resultMsg;
    }

    @Override
    public List<EpiparaAtacSeqRespVO> list2(EpiparaAtacSeqReqVO reqVO) {
        return epiparaAtacSeqMapper.list2(reqVO);
    }
}
